/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author atikahSH
 */

@Entity
@Table(name = "obats", catalog = "apoltek", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Obat.findAll", query = "SELECT e FROM Obat e"),
    @NamedQuery(name = "Obat.findByIdObat", query = "SELECT e FROM Obat e WHERE e.idObat = :idObat"),
    @NamedQuery(name = "Obat.findByNamaObat", query = "SELECT e FROM Obat e WHERE e.namaObat = :namaObat"),
    @NamedQuery(name = "Obat.findByBentukObat", query = "SELECT e FROM Obat e WHERE e.bentukObat = :bentukObat"),
    @NamedQuery(name = "Obat.findByDeskripsi", query = "SELECT e FROM Obat e WHERE e.deskripsi = :deskripsi"),
    @NamedQuery(name = "Obat.findByTanggal", query = "SELECT e FROM Obat e WHERE e.tanggal = :tanggal"),
    @NamedQuery(name = "Obat.findByGambar", query = "SELECT e FROM Obat e WHERE e.gambar = :gambar"),
    @NamedQuery(name = "Obat.findByHargaObat", query = "SELECT e FROM Obat e WHERE e.hargaObat = :hargaObat"),
    @NamedQuery(name = "Obat.findByKuantitas", query = "SELECT e FROM Obat e WHERE e.kuantitas = :kuantitas")})
public class Obat implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_OBAT", nullable = false)
    private Integer idObat;
    @Column(name = "NAMA_OBAT", length = 100)
    private String namaObat;
    @Column(name = "BENTUK_OBAT", length = 100)
    private String bentukObat;
    @Column(name = "DESKRIPSI", length = 100)
    private String deskripsi;
    @Column(name = "TANGGAL", length = 20)
    private String tanggal;
    @Column(name = "GAMBAR", length = 100)
    private String gambar;
    @Column(name = "HARGA_OBAT")
    private Integer hargaObat;
    @Column(name = "KUANTITAS", length = 100)
    private String kuantitas;
    @OneToMany(mappedBy = "idObat", fetch = FetchType.LAZY)
    private List<HistoryOrder> historyOrderList;
    @JoinColumn(name = "ID_USER", referencedColumnName = "ID_USER")
    @ManyToOne(fetch = FetchType.LAZY)
    private User idUser;

    public Obat() {
    }

    public Obat(Integer idObat) {
        this.idObat = idObat;
    }

    public Integer getIdObat() {
        return idObat;
    }

    public void setIdObat(Integer idObat) {
        this.idObat = idObat;
    }

    public String getNamaObat() {
        return namaObat;
    }

    public void setNamaObat(String namaObat) {
        this.namaObat = namaObat;
    }

    public String getBentukObat() {
        return bentukObat;
    }

    public void setBentukObat(String bentukObat) {
        this.bentukObat = bentukObat;
    }

    public String getDeskripsi() {
        return deskripsi;
    }

    public void setDeskripsi(String deskripsi) {
        this.deskripsi = deskripsi;
    }

    public String getTanggal() {
        return tanggal;
    }

    public void setTanggal(String tanggal) {
        this.tanggal = tanggal;
    }

    public String getGambar() {
        return gambar;
    }

    public void setGambar(String gambar) {
        this.gambar = gambar;
    }

    public Integer getHargaObat() {
        return hargaObat;
    }

    public void setHargaObat(Integer hargaObat) {
        this.hargaObat = hargaObat;
    }

    public String getKuantitas() {
        return kuantitas;
    }

    public void setKuantitas(String kuantitas) {
        this.kuantitas = kuantitas;
    }

    @XmlTransient
    public List<HistoryOrder> getHistoryOrderList() {
        return historyOrderList;
    }

    public void setHistoryOrderList(List<HistoryOrder> historyOrderList) {
        this.historyOrderList = historyOrderList;
    }

    public User getIdUser() {
        return idUser;
    }

    public void setIdUser(User idUser) {
        this.idUser = idUser;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idObat != null ? idObat.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Obat)) {
            return false;
        }
        Obat other = (Obat) object;
        if ((this.idObat == null && other.idObat != null) || (this.idObat != null && !this.idObat.equals(other.idObat))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.Obat[ idObat=" + idObat + " ]";
    }

}
